package com.ipay.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ipay.entity.CheckingEntity;
import com.ipay.lang.RunnableWithReturn;
import com.ipay.redis.JedisConnectionPool;
import com.ipay.redis.JedisManager;
import com.ipay.service.CheckingService;
import com.ipay.utils.PageUtils;
import com.ipay.utils.Query;
import com.ipay.utils.R;


/**
 * 银行对账流水
 * 
 * @author hacken
 * @email hacken_hu@163.com
 * @date 2017-06-14 21:31:32
 */
@RestController
@RequestMapping("checking")
public class CheckingController {
	@Autowired
	private CheckingService checkingService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("checking:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<CheckingEntity> checkingList = checkingService.queryList(query);
		int total = checkingService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(checkingList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("checking:info")
	public R info(@PathVariable("id") String id){
		CheckingEntity checking = checkingService.queryObject(id);
		
		return R.ok().put("checking", checking);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("checking:save")
	public R save(@RequestBody CheckingEntity checking){
		checkingService.save(checking);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("checking:update")
	public R update(@RequestBody CheckingEntity checking){
		checkingService.update(checking);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("checking:delete")
	public R delete(@RequestBody String[] ids){
		checkingService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
